package core.semantics.util;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;

public class GlobalContext {

	private List<Import> imports;
	private List<Procedure> procedures;

	public GlobalContext() {
		this.imports = new LinkedList<Import>();
		this.procedures = new LinkedList<Procedure>();
	}

	public void addImport(Import importt) {
		this.imports.add(importt);
	}
	
	public Import getImport(String importName) {
		for (Import importt : imports) {
			if (importt.getName().equals(importName)) {
				return importt;
			}
		}
		
		return null;
	}
	
	public List<Procedure> getProcedures() {
		return procedures;
	}
	
	public List<Import> getImports() {
		return imports;
	}
	
	public void addProcedure(Procedure procedure) {
		this.procedures.add(procedure);
	}
	
	public Procedure getProcedure(String procedureName) {
		for (Procedure procedure : procedures) {
			if (procedure.getName().equals(procedureName)) {
				return procedure;
			}
		}
		
		return null;
	}

	@Override
	public String toString() {
		return Arrays.toString(imports.toArray());
	}
	
}
